package androidx.fragment.app;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class ListFragment extends Fragment {
    View ʼ;
    CharSequence ʽ;
    TextView ˊ;
    View ˋ;
    ListView ˎ;
    View ˏ;
    ListAdapter ॱ;
    private final Handler ॱॱ = new Handler();
    boolean ᐝ;
    private final OnItemClickListener ﹳ = new OnItemClickListener(this) {
        final /* synthetic */ ListFragment ˊ;

        {
            this.ˊ = r1;
        }

        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
            this.ˊ.ˎ((ListView) adapterView, view, i, j);
        }
    };
    private final Runnable ﾟ = new Runnable(this) {
        final /* synthetic */ ListFragment ˋ;

        {
            this.ˋ = r1;
        }

        public void run() {
            this.ˋ.ˎ.focusableViewAvailable(this.ˋ.ˎ);
        }
    };

    @Nullable
    public View ˋ(@NonNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
        Context ˏॱ = ˏॱ();
        View frameLayout = new FrameLayout(ˏॱ);
        View linearLayout = new LinearLayout(ˏॱ);
        linearLayout.setId(16711682);
        linearLayout.setOrientation(1);
        linearLayout.setVisibility(8);
        linearLayout.setGravity(17);
        linearLayout.addView(new ProgressBar(ˏॱ, null, 16842874), new LayoutParams(-2, -2));
        frameLayout.addView(linearLayout, new LayoutParams(-1, -1));
        linearLayout = new FrameLayout(ˏॱ);
        linearLayout.setId(16711683);
        View textView = new TextView(ˏॱ);
        textView.setId(16711681);
        textView.setGravity(17);
        linearLayout.addView(textView, new LayoutParams(-1, -1));
        textView = new ListView(ˏॱ);
        textView.setId(16908298);
        textView.setDrawSelectorOnTop(false);
        linearLayout.addView(textView, new LayoutParams(-1, -1));
        frameLayout.addView(linearLayout, new LayoutParams(-1, -1));
        frameLayout.setLayoutParams(new LayoutParams(-1, -1));
        return frameLayout;
    }

    public void ˊ(@NonNull View view, @Nullable Bundle bundle) {
        super.ˊ(view, bundle);
        ॱ();
    }

    public void ᐝ() {
        this.ॱॱ.removeCallbacks(this.ﾟ);
        this.ˎ = null;
        this.ᐝ = false;
        this.ʼ = null;
        this.ˏ = null;
        this.ˋ = null;
        this.ˊ = null;
        super.ᐝ();
    }

    public void ˎ(@NonNull ListView listView, @NonNull View view, int i, long j) {
    }

    public void ˎ(@Nullable ListAdapter listAdapter) {
        boolean z = false;
        boolean z2 = this.ॱ != null;
        this.ॱ = listAdapter;
        if (this.ˎ != null) {
            this.ˎ.setAdapter(listAdapter);
            if (!this.ᐝ && !z2) {
                if (ˊˊ().getWindowToken() != null) {
                    z = true;
                }
                ˏ(true, z);
            }
        }
    }

    private void ˏ(boolean z, boolean z2) {
        ॱ();
        if (this.ˏ == null) {
            throw new IllegalStateException("Can't be used with a custom content view");
        } else if (this.ᐝ != z) {
            this.ᐝ = z;
            if (z) {
                if (z2) {
                    this.ˏ.startAnimation(AnimationUtils.loadAnimation(ॱˊ(), 17432577));
                    this.ʼ.startAnimation(AnimationUtils.loadAnimation(ॱˊ(), 17432576));
                } else {
                    this.ˏ.clearAnimation();
                    this.ʼ.clearAnimation();
                }
                this.ˏ.setVisibility(8);
                this.ʼ.setVisibility(0);
                return;
            }
            if (z2) {
                this.ˏ.startAnimation(AnimationUtils.loadAnimation(ॱˊ(), 17432576));
                this.ʼ.startAnimation(AnimationUtils.loadAnimation(ॱˊ(), 17432577));
            } else {
                this.ˏ.clearAnimation();
                this.ʼ.clearAnimation();
            }
            this.ˏ.setVisibility(0);
            this.ʼ.setVisibility(8);
        }
    }

    private void ॱ() {
        if (this.ˎ == null) {
            View view = getView();
            if (view == null) {
                throw new IllegalStateException("Content view not yet created");
            }
            if (view instanceof ListView) {
                this.ˎ = (ListView) view;
            } else {
                this.ˊ = (TextView) view.findViewById(16711681);
                if (this.ˊ == null) {
                    this.ˋ = view.findViewById(16908292);
                } else {
                    this.ˊ.setVisibility(8);
                }
                this.ˏ = view.findViewById(16711682);
                this.ʼ = view.findViewById(16711683);
                view = view.findViewById(16908298);
                if (view instanceof ListView) {
                    this.ˎ = (ListView) view;
                    if (this.ˋ != null) {
                        this.ˎ.setEmptyView(this.ˋ);
                    } else if (this.ʽ != null) {
                        this.ˊ.setText(this.ʽ);
                        this.ˎ.setEmptyView(this.ˊ);
                    }
                } else if (view == null) {
                    throw new RuntimeException("Your content must have a ListView whose id attribute is 'android.R.id.list'");
                } else {
                    throw new RuntimeException("Content has view with id attribute 'android.R.id.list' that is not a ListView class");
                }
            }
            this.ᐝ = true;
            this.ˎ.setOnItemClickListener(this.ﹳ);
            if (this.ॱ != null) {
                ListAdapter listAdapter = this.ॱ;
                this.ॱ = null;
                ˎ(listAdapter);
            } else if (this.ˏ != null) {
                ˏ(false, false);
            }
            this.ॱॱ.post(this.ﾟ);
        }
    }
}
